View Javadoc

1   // ELF.java, created Sat May 25 12:46:16 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Linker.ELF;
5   
6   import java.util.List;
7   import java.io.IOException;
8   
9   /***
10   * @author John Whaley <jwhaley@alum.mit.edu>
11   * @version $Id: ELF.java 1941 2004-09-30 03:37:06Z joewhaley $
12   */
13  public interface ELF {
14      
15      //// READ-ONLY METHODS
16      
17      /***
18       * Returns the list of ELF sections in this object.
19       * @return list of ELF sections in this object
20       */
21      List getSections();
22      
23      Section getSection(int index);
24      
25      /***
26       * Returns the section header string table, if one has been defined.
27       * Or null otherwise.
28       * @return section header string table
29       */
30      Section.StrTabSection getSectionHeaderStringTable();
31      
32      /***
33       * Returns true if this ELF object is little-endian.
34       * @return true if this ELF object is little-endian
35       */
36      boolean isLittleEndian();
37      
38      /***
39       * Returns true if this ELF object is big-endian.
40       * @return true if this ELF object is big-endian
41       */
42      boolean isBigEndian();
43      
44      //// UPDATING METHODS
45      
46      /***
47       * Sets the section header string table to be the given section.
48       * @param shstrtab new section header string table
49       */
50      void setSectionHeaderStringTable(Section.StrTabSection shstrtab);
51      
52      /***
53       * Adds the given ELF section to this object.
54       * @param s section to add
55       */
56      void addSection(Section s);
57      
58      /***
59       * Removes the given ELF section from this object.
60       * @param s section to remove
61       */
62      void removeSection(Section s);
63      
64      /***
65       * Adds the given ELF program header to this object.
66       * @param p program header to add
67       */
68      void addProgramHeader(ProgramHeader p);
69      
70      /***
71       * Removes the given ELF program header from this object.
72       * @param p program header to remove
73       */
74      void removeProgramHeader(ProgramHeader p);
75      
76      void setLittleEndian();
77      void setBigEndian();
78      
79      void write() throws IOException;
80      
81      void write_byte(byte v) throws IOException;
82      void write_bytes(byte[] v) throws IOException;
83      void write_half(int v) throws IOException;
84      void write_word(int v) throws IOException;
85      void write_sword(int v) throws IOException;
86      void write_off(int v) throws IOException;
87      void write_addr(int v) throws IOException;
88      void write_sectionname(String s) throws IOException;
89      
90      void set_position(int offset) throws IOException;
91      byte read_byte() throws IOException;
92      void read_bytes(byte[] b) throws IOException;
93      int read_half() throws IOException;
94      int read_word() throws IOException;
95      int read_sword() throws IOException;
96      int read_off() throws IOException;
97      int read_addr() throws IOException;
98      
99  }